package com.itheima.hashmap;

import java.util.HashMap;
import java.util.Map;
import java.util.Set;

public class HashMapDemo {
    public static void main(String[] args) {
        HashMap<Student, String> hm = new HashMap<>();
        Student s1=new Student("yy","18","男");
        Student s2=new Student("yyds","14","男");
        Student s3=new Student("yymm","18","nv");
        hm.put(s1,"安徽");
        hm.put(s2,"上海");
        hm.put(s3,"北京");
        //方式1
        System.out.println("-----------------");
        Set<Student> keys = hm.keySet();
        for (Student key : keys) {
            System.out.println(key+hm.get(key));
        }
        System.out.println("-----------------");
        //方式2
        Set<Map.Entry<Student, String>> entries = hm.entrySet();
        for (Map.Entry<Student, String> entry : entries) {
            System.out.println(entry);
        }
        System.out.println("-----------------");
        //方式3通过lambda表达式传参，直接定义数据处理方式
        hm.forEach((Student st,String s)->{
            System.out.println(st.toString()+s);
        });

    }
}
